import {
  Body,
  Controller,
  Get,
  Post,
  Query,
  Request,
  UseGuards,
} from '@nestjs/common';
import { VideoItemService } from './video-item.service';
import { AuthGuard } from '@nestjs/passport';

@Controller('videoItem')
export class VideoItemController {
  constructor(private readonly videoItemService: VideoItemService) {}

  @Get()
  // 查询视频列表
  getVideoItemList(@Query() params) {
    return this.videoItemService.getVideoItemList(params);
  }

  @Post('add')
  @UseGuards(AuthGuard('jwt'))
  // 创建视频item
  addVideoItem(@Body() bodyData) {
    return this.videoItemService.addVideoItem(bodyData);
  }

  @Post('edit')
  @UseGuards(AuthGuard('jwt'))
  // 修改视频item
  editVideoItem(@Body() bodyData) {
    return this.videoItemService.editVideoItem(bodyData);
  }

  @Get('delete')
  @UseGuards(AuthGuard('jwt'))
  // 删除uipitem
  deleteVideoItem(@Query() params) {
    return this.videoItemService.deleteVideoItem(params);
  }

  @Get('getHistoryList')
  @UseGuards(AuthGuard('jwt'))
  getHistoryList(@Request() req) {
    return this.videoItemService.getHistoryList({
      userId: req.user.id,
    });
  }

  @Get('getHistoryOne')
  @UseGuards(AuthGuard('jwt'))
  getHistoryOne(@Request() req,@Query() params) {
    return this.videoItemService.getHistoryOne({
      userId: req.user.id,
      ...params,
    });
  }

  @Post('addHistory')
  @UseGuards(AuthGuard('jwt'))
  // 添加历史记录
  addHistory(@Request() req, @Body() bodyData) {
    return this.videoItemService.addHistory({
      ...bodyData,
      userId: req.user.id,
    });
  }

  @Get('deleteHistory')
  @UseGuards(AuthGuard('jwt'))
  // 删除历史记录
  deleteHistory(@Query() params) {
    return this.videoItemService.deleteHistory(params);
  }
}
